home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Misc / Cookie / Source / BattleZoneView.m < prev    next >
Encoding:
Text File  |  1995-06-12  |  1.3 KB  |  89 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. #import "BattleZoneView.h"
  5.  
  6. void RunBattleEntry(DPSTimedEntry te, double timeNow, void *data)
  7. {
  8.   /* we set data to self so we can call this method from the timed entry */
  9.     [(BattleZoneView *)data display];
  10. }
  11.  
  12. void DisplayBattleFrame(float width,float height,float *Lines);
  13.  
  14. @implementation BattleZoneView
  15.  
  16. - drawSelf:(const NXRect *)rects :(int)rectCount
  17. {
  18.     int count;
  19.     float myLines[5];
  20.  
  21.     if(step == -1)
  22.     {
  23.         PSsetgray(0.0);
  24.         NXRectFill(&bounds);
  25.         step = 0;
  26.     }
  27.  
  28.     for(count = 0; count < 5; count++)
  29.         myLines[count] = Lines[(count*10)+step];
  30.  
  31.     myLines[0] = Lines[0];
  32.  
  33.     step++;
  34.     if(step == 10)
  35.         step = 0;
  36.  
  37.     DisplayBattleFrame(bounds.size.width,bounds.size.height,myLines);
  38.  
  39.     return self;
  40. }
  41.  
  42. - startAnimation
  43. {
  44.     myTimedEntry =
  45.         DPSAddTimedEntry((float)0.02,
  46.             &RunBattleEntry,self,NX_BASETHRESHOLD);
  47.  
  48.     return self;
  49. }
  50.  
  51. - endAnimation
  52. {
  53.     DPSRemoveTimedEntry(myTimedEntry);
  54.  
  55.     return self;
  56. }
  57.  
  58. - initFrame:(const NXRect *)frameRect
  59. {
  60.     int count;
  61.     float totalSize = 0.0,Delta = 1.0,sofa = 0.0;
  62.  
  63. #define height frameRect->size.height
  64.  
  65.     [super initFrame :frameRect];
  66.  
  67.     step = -1;
  68.  
  69.     for(count = 0; count < 50; count++)
  70.     {
  71.         totalSize += Delta;
  72.         Delta *= 1.075;
  73.     }
  74.  
  75.     Delta = 1.0;
  76.  
  77.     for(count = 0; count < 50; count++)
  78.     {
  79.         sofa += Delta;
  80.         Delta *= 1.075;
  81.  
  82.         Lines[count] = height-((sofa*height)/totalSize);
  83.     }
  84.  
  85.     return self;
  86. }
  87.  
  88. @end
  89.